package org.ailoli.aixiang.contract

import android.content.Context
import io.reactivex.rxjava3.core.Observable
import org.ailoli.aixiang.base.BaseView
import org.ailoli.aixiang.bean.BatteryBean
import org.ailoli.aixiang.bean.CabinetBean
import org.ailoli.aixiang.bean.GetQrCodeUrlBean
import org.ailoli.aixiang.bean.LoginBean
import org.ailoli.aixiang.data.BatteryData


interface MainContract {
    interface Model {
//        fun login(clientId: String?, clientSecret: String?): Flowablble<LoginBean?>?
        fun login(clientId: String?, clientSecret: String?): Observable<LoginBean?>?

        fun getQrCodeUrl(cabinetId: String): Observable<GetQrCodeUrlBean>?
    }

    interface View : BaseView {
        override fun showLoading()

        override fun hideLoading()

        override fun onError(throwable: Throwable?)

        fun setQrCodeUrl(url: String)

        fun loginCallBack (loginBean: LoginBean)

        fun onOneBatteryUpdate(index: Int, batteryData: BatteryData)

        fun onOneBatteryComplete(batteryList: ArrayList<BatteryBean>)

        fun onFetchCabinetLockComplete(cabinetBean: CabinetBean)
    }

    interface Presenter {
        /**
         * 柜子登录获取token
         */
        fun login (clientId: String, clientSecret: String)

        fun getQrCodeUrl(cabinetId: String)

        fun getAllSerialPort(): Array<String>?

        fun sendDataToSerialPort()

        fun sendDataToUsb(context: Context)

        fun initUsb(context: Context)

        fun getBatteryInfoByBoxId(context: Context, boxId: Int): ByteArray

        fun updateAllBattery(context: Context, batteryList: ArrayList<BatteryBean>)

        // 测试开门
        fun openDoor()

        fun closeDoor()

        fun updateAllBox(context: Context)
    }
}